<template>
  <div class="login_container">
    <div class="login_box">
      <div class="avater_box"></div>
      <el-form class="login_form">
        <el-form-item
          :rules="[
            {
              required: true,
              message: 'Please input username',
              trigger: 'blur',
            }]"
        >
          <el-input v-model="loginForm.user_name" />
        </el-form-item>
      </el-form>
      <el-form class="register_form">
        <el-form-item>
          <el-input v-model="loginForm.user_pwd" />
        </el-form-item>
      </el-form>
      <el-button class="loginBtn" type="primary" @click="managerLogin">登录</el-button>
    </div>
  </div>
</template>

<script>
import { ElForm,ElFormItem,ElInput,ElButton } from 'element-plus'
export default {
  // eslint-disable-next-line vue/no-unused-components
  components: { ElForm,ElFormItem,ElInput,ElButton },
  data() {
    return {
      loginForm:{
        user_name: 'smz',
        user_pwd: '123456'
      }
    }
  },
  methods:{
    async managerLogin() {
      const res = await this.$api.login.managerLogin(this.loginForm)
      if(res.data.status === 0) {
        console.log('登录成功!')
        const { token } = res.data
        localStorage.setItem('Authorization',token)
        this.$router.push({ path:'/managermain' })
      }else {
        console.log('登陆失败!')
      }
    }
  }
}

</script>

<style lang="scss" scoped>
.login_container{
    background-color: #2b4b6b;
    height: 100%;
}

.login_box{
    width: 450px;
    height: 300px;
    background-color: #fff;
    position: absolute;
    left:50%;
    top: 50%;
    transform: translate(-50%,-50%);

     .avater_box{
      height: 130px;
      width: 130px;
      border: 1px solid #eee;
      border-radius: 50%;
      padding: 10px;
      box-shadow: 0 0 10px #ddd;
      position: absolute;
      left: 50%;
      transform: translate(-50%,-50%);
      background-color: #fff;
     }
     .login_form {
         margin-top: 100px;
         padding: 0 30px 0 30px;
     }
     .register_form {
         margin-top: 30px;
         padding: 0 30px 0 30px;
     }
     .loginBtn {
         margin-left: 180px;
     }

}
</style>
